package astar;

public class Benchmark {

    public static void benchmarkSmallArea() {
        int[][] impassablePoints = {
                                {5,0},{5,1},{5,2},{5,3},{5,4},        {5,6},{5,7},{5,8},{5,9},
                                
                                {7,0},{7,1},{7,2},       {7,4}, {7,5}, {7,6},{7,7},{7,8},{7,9}
                            };
        Area area = new Area(10, 10);
        for(int[] point:impassablePoints) {
            area.edit(point[0], point[1], AStarConstants.TERRAIN_IMPASSABLE);
        }
        AStar aStar = new AStar();
        
        Path path = aStar.getPath(0, 0, 9, 9, area, 3);
        System.out.println(area.toString(path));
        System.out.println("benchmarkSmallArea1: "+path.computeTimeMs+" ms");
        path = aStar.getPath(0, 0, 9, 9, area, 3);
        System.out.println("benchmarkSmallArea2: "+path.computeTimeMs+" ms");
        path = aStar.getPath(0, 0, 9, 9, area, 3);
        System.out.println("benchmarkSmallArea3: "+path.computeTimeMs+" ms");
    }
    
    public static void benchmarkMediumArea() {
        int[][] impassablePoints = {
                                    {5,0},{5,1},{5,2},{5,3},{5,4},        {5,6},{5,7},{5,8},{5,9},{5,10},{5,11},{5,12},{5,13},{5,14},
                                    
                                    {7,0},{7,1},{7,2},       {7,4}, {7,5}, {7,6},{7,7},{7,8},{7,9},{7,10},{7,11},{7,12},{7,13},{7,14}
                                };
        Area area = new Area(25, 25);
        for(int[] point:impassablePoints) {
            area.edit(point[0], point[1], AStarConstants.TERRAIN_IMPASSABLE);
        }
        AStar aStar = new AStar();
        
        Path path = aStar.getPath(0, 0, 24, 24, area, 3);
        System.out.println(area.toString(path));
        System.out.println("benchmarkMediumArea1: "+path.computeTimeMs+" ms");
        path = aStar.getPath(0, 0, 24, 24, area, 3);
        System.out.println("benchmarkMediumArea2: "+path.computeTimeMs+" ms");
        path = aStar.getPath(0, 0, 24, 24, area, 3);
        System.out.println("benchmarkMediumArea3: "+path.computeTimeMs+" ms");
    }
    
    public static void benchmarkLargeArea() {
        int[][] impassablePoints = {
                                    {5,0},{5,1},{5,2},{5,3},{5,4},        {5,6},{5,7},{5,8},{5,9},{5,10},{5,11},{5,12},{5,13},{5,14},
                                    
                                    {7,0},{7,1},{7,2},       {7,4}, {7,5}, {7,6},{7,7},{7,8},{7,9},{7,10},{7,11},{7,12},{7,13},{7,14}
                                };
        Area area = new Area(50, 50);
        for(int[] point:impassablePoints) {
            area.edit(point[0], point[1], AStarConstants.TERRAIN_IMPASSABLE);
        }
        AStar aStar = new AStar();
        
        Path path = aStar.getPath(0, 0, 49, 49, area, 3);
        System.out.println(area.toString(path));
        System.out.println("benchmarkLargeArea1: "+path.computeTimeMs+" ms");
        path = aStar.getPath(0, 0, 49, 49, area, 3);
        System.out.println("benchmarkLargeArea2: "+path.computeTimeMs+" ms");
        path = aStar.getPath(0, 0, 49, 49, area, 3);
        System.out.println("benchmarkLargeArea3: "+path.computeTimeMs+" ms");
    }
    
    public static void main(String[] args) {
        benchmarkSmallArea();
        benchmarkMediumArea();
        benchmarkLargeArea();
    }
}
